
<!doctype html>
<html lang="en" class="no-js">
  <head>
    
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width,initial-scale=1">
      
      
      
      <link rel="icon" href="../../../../static/images/favicon.png">
      <meta name="generator" content="mkdocs-1.3.0, mkdocs-material-8.2.8">
    
    
      
        <title>部署 IPVS 高可用软 LB 集群 - WL4G DOCS</title>
      
    
    
      <link rel="stylesheet" href="../../../../assets/stylesheets/main.644de097.min.css">
      
        
        <link rel="stylesheet" href="../../../../assets/stylesheets/palette.e6a45f82.min.css">
        
      
    
    
    
      
        
        
        <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
        <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i%7CRoboto+Mono:400,400i,700,700i&display=fallback">
        <style>:root{--md-text-font:"Roboto";--md-code-font:"Roboto Mono"}</style>
      
    
    
      <link rel="stylesheet" href="../../../../static/css/util.css">
    
    <script>__md_scope=new URL("../../../..",location),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script>
    
      

    
    
  </head>
  
  
    
    
      
    
    
    
    
    <body dir="ltr" data-md-color-scheme="default" data-md-color-primary="" data-md-color-accent="">
  
    
    
      <script>var palette=__md_get("__palette");if(palette&&"object"==typeof palette.color)for(var key of Object.keys(palette.color))document.body.setAttribute("data-md-color-"+key,palette.color[key])</script>
    
    <input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off">
    <input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
    <label class="md-overlay" for="__drawer"></label>
    <div data-md-component="skip">
      
        
        <a href="#ipvs-lb" class="md-skip">
          Skip to content
        </a>
      
    </div>
    <div data-md-component="announce">
      
    </div>
    
      <div data-md-component="outdated" hidden>
        <aside class="md-banner md-banner--warning">
          
        </aside>
      </div>
    
    
      

<header class="md-header" data-md-component="header">
  <nav class="md-header__inner md-grid" aria-label="Header">
    <a href="../../../.." title="WL4G DOCS" class="md-header__button md-logo" aria-label="WL4G DOCS" data-md-component="logo">
      
  <img src="../../../../static/images/mylogo.jpeg" alt="logo">

    </a>
    <label class="md-header__button md-icon" for="__drawer">
      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 6h18v2H3V6m0 5h18v2H3v-2m0 5h18v2H3v-2z"/></svg>
    </label>
    <div class="md-header__title" data-md-component="header-title">
      <div class="md-header__ellipsis">
        <div class="md-header__topic">
          <span class="md-ellipsis">
            WL4G DOCS
          </span>
        </div>
        <div class="md-header__topic" data-md-component="header-topic">
          <span class="md-ellipsis">
            
              部署 IPVS 高可用软 LB 集群
            
          </span>
        </div>
      </div>
    </div>
    
      <form class="md-header__option" data-md-component="palette">
        
          
          
          <input class="md-option" data-md-color-media="(prefers-color-scheme: light)" data-md-color-scheme="default" data-md-color-primary="" data-md-color-accent=""  aria-label="Switch to dark mode"  type="radio" name="__palette" id="__palette_1">
          
            <label class="md-header__button md-icon" title="Switch to dark mode" for="__palette_2" hidden>
              <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M17 6H7c-3.31 0-6 2.69-6 6s2.69 6 6 6h10c3.31 0 6-2.69 6-6s-2.69-6-6-6zm0 10H7c-2.21 0-4-1.79-4-4s1.79-4 4-4h10c2.21 0 4 1.79 4 4s-1.79 4-4 4zM7 9c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z"/></svg>
            </label>
          
        
          
          
          <input class="md-option" data-md-color-media="(prefers-color-scheme: dark)" data-md-color-scheme="slate" data-md-color-primary="" data-md-color-accent=""  aria-label="Switch to light mode"  type="radio" name="__palette" id="__palette_2">
          
            <label class="md-header__button md-icon" title="Switch to light mode" for="__palette_1" hidden>
              <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M17 7H7a5 5 0 0 0-5 5 5 5 0 0 0 5 5h10a5 5 0 0 0 5-5 5 5 0 0 0-5-5m0 8a3 3 0 0 1-3-3 3 3 0 0 1 3-3 3 3 0 0 1 3 3 3 3 0 0 1-3 3z"/></svg>
            </label>
          
        
      </form>
    
    
      <div class="md-header__option">
        <div class="md-select">
          
          <button class="md-header__button md-icon" aria-label="Select language">
            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="m12.87 15.07-2.54-2.51.03-.03A17.52 17.52 0 0 0 14.07 6H17V4h-7V2H8v2H1v2h11.17C11.5 7.92 10.44 9.75 9 11.35 8.07 10.32 7.3 9.19 6.69 8h-2c.73 1.63 1.73 3.17 2.98 4.56l-5.09 5.02L4 19l5-5 3.11 3.11.76-2.04M18.5 10h-2L12 22h2l1.12-3h4.75L21 22h2l-4.5-12m-2.62 7 1.62-4.33L19.12 17h-3.24z"/></svg>
          </button>
          <div class="md-select__inner">
            <ul class="md-select__list">
              
                <li class="md-select__item">
                  <a href="/en/" hreflang="en" class="md-select__link">
                    English
                  </a>
                </li>
                
                <li class="md-select__item">
                  <a href="/zh/" hreflang="zh" class="md-select__link">
                    简体中文
                  </a>
                </li>
                
            </ul>
          </div>
        </div>
      </div>
    
    
      <label class="md-header__button md-icon" for="__search">
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5z"/></svg>
      </label>
      <div class="md-search" data-md-component="search" role="dialog">
  <label class="md-search__overlay" for="__search"></label>
  <div class="md-search__inner" role="search">
    <form class="md-search__form" name="search">
      <input type="text" class="md-search__input" name="query" aria-label="Search" placeholder="Search" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="search-query" required>
      <label class="md-search__icon md-icon" for="__search">
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5z"/></svg>
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12z"/></svg>
      </label>
      <nav class="md-search__options" aria-label="Search">
        
        <button type="reset" class="md-search__icon md-icon" aria-label="Clear" tabindex="-1">
          <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"/></svg>
        </button>
      </nav>
      
        <div class="md-search__suggest" data-md-component="search-suggest"></div>
      
    </form>
    <div class="md-search__output">
      <div class="md-search__scrollwrap" data-md-scrollfix>
        <div class="md-search-result" data-md-component="search-result">
          <div class="md-search-result__meta">
            Initializing search
          </div>
          <ol class="md-search-result__list"></ol>
        </div>
      </div>
    </div>
  </div>
</div>
    
    
  </nav>
  
</header>
    
    <div class="md-container" data-md-component="container">
      
      
        
          
            
<nav class="md-tabs" aria-label="Tabs" data-md-component="tabs">
  <div class="md-tabs__inner md-grid">
    <ul class="md-tabs__list">
      
        
  
  


  
  
  
    <li class="md-tabs__item">
      <a href="../../../.." class="md-tabs__link">
        Getting Started
      </a>
    </li>
  

      
    </ul>
  </div>
</nav>
          
        
      
      <main class="md-main" data-md-component="main">
        <div class="md-main__inner md-grid">
          
            
              
              <div class="md-sidebar md-sidebar--primary" data-md-component="sidebar" data-md-type="navigation" >
                <div class="md-sidebar__scrollwrap">
                  <div class="md-sidebar__inner">
                    

  


  

<nav class="md-nav md-nav--primary md-nav--lifted md-nav--integrated" aria-label="Navigation" data-md-level="0">
  <label class="md-nav__title" for="__drawer">
    <a href="../../../.." title="WL4G DOCS" class="md-nav__button md-logo" aria-label="WL4G DOCS" data-md-component="logo">
      
  <img src="../../../../static/images/mylogo.jpeg" alt="logo">

    </a>
    WL4G DOCS
  </label>
  
  <ul class="md-nav__list" data-md-scrollfix>
    
      
      
      

  
  
  
    
    <li class="md-nav__item md-nav__item--nested">
      
      
        <input class="md-nav__toggle md-toggle" data-md-toggle="__nav_1" data-md-state="indeterminate" type="checkbox" id="__nav_1" checked>
      
      
      
      
        <label class="md-nav__link" for="__nav_1">
          Getting Started
          <span class="md-nav__icon md-icon"></span>
        </label>
      
      <nav class="md-nav" aria-label="Getting Started" data-md-level="1">
        <label class="md-nav__title" for="__nav_1">
          <span class="md-nav__icon md-icon"></span>
          Getting Started
        </label>
        <ul class="md-nav__list" data-md-scrollfix>
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../../.." class="md-nav__link">
        Introduction
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../../../ABOUT_CN/" class="md-nav__link">
        About
      </a>
    </li>
  

            
          
        </ul>
      </nav>
    </li>
  

    
  </ul>
</nav>
                  </div>
                </div>
              </div>
            
            
          
          <div class="md-content" data-md-component="content">
            <article class="md-content__inner md-typeset">
              
                


<h1 id="ipvs-lb">部署 IPVS 高可用软 LB 集群<a class="headerlink" href="#ipvs-lb" title="Permanent link">&para;</a></h1>
<p>ipvs (IP Virtual Server) 是基于 Netfilter 的，作为 linux 内核的一部分实现了传输层负载均衡，ipvs 集成在LVS(Linux Virtual Server)中，它在主机中运行，并在真实服务器集群前充当负载均衡器。ipvs 可以将对 TCP/UDP 服务的请求转发给后端的真实服务器，因此 ipvs 天然支持 Kubernetes Service。ipvs 也包含了多种不同的负载均衡算法，例如轮询、最短期望延迟、最少连接以及各种哈希方法等，ipvs 的设计就是用来为大规模服务进行负载均衡的。</p>
<p><strong><em>ipvs 有三种负载均衡方式，分别为：</em></strong></p>
<ul>
<li><a href="http://www.linuxvirtualserver.org/VS-NAT.html">NAT</a>  --- 此模式，ipvs 节点相当于路由器（网关角色）。</li>
<li><a href="http://www.linuxvirtualserver.org/VS-IPTunneling.html">TUN</a></li>
<li><a href="http://www.linuxvirtualserver.org/VS-DRouting.html">DR</a></li>
</ul>
<h2 id="1">1. 下载安装<a class="headerlink" href="#1" title="Permanent link">&para;</a></h2>
<h3 id="11">1.1 在线安装<a class="headerlink" href="#11" title="Permanent link">&para;</a></h3>
<div class="highlight"><pre><span></span><code><a id="__codelineno-0-1" name="__codelineno-0-1"></a><a href="#__codelineno-0-1"><span class="linenos" data-linenos="1 "></span></a>sudo yum install -y ipvsadm ipset sysstat conntrack libseccomp
<a id="__codelineno-0-2" name="__codelineno-0-2"></a><a href="#__codelineno-0-2"><span class="linenos" data-linenos="2 "></span></a><span class="c1"># 或</span>
<a id="__codelineno-0-3" name="__codelineno-0-3"></a><a href="#__codelineno-0-3"><span class="linenos" data-linenos="3 "></span></a>sudo apt install -y ipvsadm ipset sysstat conntrack libseccomp2
</code></pre></div>
<h3 id="12">1.2 离线安装<a class="headerlink" href="#12" title="Permanent link">&para;</a></h3>
<h4 id="121">1.2.1 基于源码编译离线安装<a class="headerlink" href="#121" title="Permanent link">&para;</a></h4>
<ul>
<li>首先去官网 <a href="http://www.linuxvirtualserver.org/software/ipvs.html">http://www.linuxvirtualserver.org/software/ipvs.html</a> 下载匹配 kernel 版本的 ipvs 包</li>
</ul>
<div class="highlight"><pre><span></span><code><a id="__codelineno-1-1" name="__codelineno-1-1"></a><a href="#__codelineno-1-1"><span class="linenos" data-linenos=" 1 "></span></a><span class="nb">cd</span> /tmp
<a id="__codelineno-1-2" name="__codelineno-1-2"></a><a href="#__codelineno-1-2"><span class="linenos" data-linenos=" 2 "></span></a>wget http://www.linuxvirtualserver.org/software/kernel-2.6/ipvsadm-1.26.tar.gz
<a id="__codelineno-1-3" name="__codelineno-1-3"></a><a href="#__codelineno-1-3"><span class="linenos" data-linenos=" 3 "></span></a>tar -zxvf ipvsadm-*.tar.gz
<a id="__codelineno-1-4" name="__codelineno-1-4"></a><a href="#__codelineno-1-4"><span class="linenos" data-linenos=" 4 "></span></a><span class="nb">cd</span> ipvsadm-*
<a id="__codelineno-1-5" name="__codelineno-1-5"></a><a href="#__codelineno-1-5"><span class="linenos" data-linenos=" 5 "></span></a><span class="c1"># 建立编译时必须的一个软链接</span>
<a id="__codelineno-1-6" name="__codelineno-1-6"></a><a href="#__codelineno-1-6"><span class="linenos" data-linenos=" 6 "></span></a>ln -s /usr/src/kernels/2.6.9-42.EL-i686/ /usr/src/linux
<a id="__codelineno-1-7" name="__codelineno-1-7"></a><a href="#__codelineno-1-7"><span class="linenos" data-linenos=" 7 "></span></a><span class="c1"># 编译安装</span>
<a id="__codelineno-1-8" name="__codelineno-1-8"></a><a href="#__codelineno-1-8"><span class="linenos" data-linenos=" 8 "></span></a>make <span class="o">&amp;&amp;</span> make install
<a id="__codelineno-1-9" name="__codelineno-1-9"></a><a href="#__codelineno-1-9"><span class="linenos" data-linenos=" 9 "></span></a><span class="c1"># 检查安装成功</span>
<a id="__codelineno-1-10" name="__codelineno-1-10"></a><a href="#__codelineno-1-10"><span class="linenos" data-linenos="10 "></span></a>whereis ipvsadm
</code></pre></div>
<h4 id="122">1.2.2 拷贝二进制离线安装<a class="headerlink" href="#122" title="Permanent link">&para;</a></h4>
<ul>
<li>首先检查 kernel 中 ipvs 模块文件，建议使用 CentOS 7+、Ubuntu 18 + 或同族系统版本，因为他们的 kernel 版本默认内置 ipvs 模块。</li>
</ul>
<div class="highlight"><pre><span></span><code><a id="__codelineno-2-1" name="__codelineno-2-1"></a><a href="#__codelineno-2-1"><span class="linenos" data-linenos="1 "></span></a>sudo ls -al /usr/lib/modules/*/kernel/net/netfilter/ipvs/
</code></pre></div>
<ul>
<li>
<p>找一台可连接公网的相同OS版本的机器，使用 yum/apt 安装，然后拷贝二进制文件: /sbin/ipvsadm、/sbin/ipvsadm-restore、/sbin/ipvsadm-save，丢到目标机器的 /sbin 目录。</p>
</li>
<li>
<p>加载及配置</p>
</li>
</ul>
<div class="highlight"><pre><span></span><code><a id="__codelineno-3-1" name="__codelineno-3-1"></a><a href="#__codelineno-3-1"><span class="linenos" data-linenos=" 1 "></span></a><span class="c1"># 先查看 ip_vs 模块加载情况</span>
<a id="__codelineno-3-2" name="__codelineno-3-2"></a><a href="#__codelineno-3-2"><span class="linenos" data-linenos=" 2 "></span></a>sudo lsmod <span class="p">|</span> grep ip_vs
<a id="__codelineno-3-3" name="__codelineno-3-3"></a><a href="#__codelineno-3-3"><span class="linenos" data-linenos=" 3 "></span></a>
<a id="__codelineno-3-4" name="__codelineno-3-4"></a><a href="#__codelineno-3-4"><span class="linenos" data-linenos=" 4 "></span></a><span class="c1"># 使用 ipvsadm 查看转发规则，如果是首次未加载，执行此命令时会加载）</span>
<a id="__codelineno-3-5" name="__codelineno-3-5"></a><a href="#__codelineno-3-5"><span class="linenos" data-linenos=" 5 "></span></a>sudo ipvsadm
<a id="__codelineno-3-6" name="__codelineno-3-6"></a><a href="#__codelineno-3-6"><span class="linenos" data-linenos=" 6 "></span></a>IP Virtual Server version <span class="m">1</span>.2.1 <span class="o">(</span><span class="nv">size</span><span class="o">=</span><span class="m">4096</span><span class="o">)</span>
<a id="__codelineno-3-7" name="__codelineno-3-7"></a><a href="#__codelineno-3-7"><span class="linenos" data-linenos=" 7 "></span></a>Prot LocalAddress:Port Scheduler Flags
<a id="__codelineno-3-8" name="__codelineno-3-8"></a><a href="#__codelineno-3-8"><span class="linenos" data-linenos=" 8 "></span></a>  -&gt; RemoteAddress:Port           Forward Weight ActiveConn InActConn
<a id="__codelineno-3-9" name="__codelineno-3-9"></a><a href="#__codelineno-3-9"><span class="linenos" data-linenos=" 9 "></span></a>
<a id="__codelineno-3-10" name="__codelineno-3-10"></a><a href="#__codelineno-3-10"><span class="linenos" data-linenos="10 "></span></a><span class="c1"># 或使用 modprobe 加载</span>
<a id="__codelineno-3-11" name="__codelineno-3-11"></a><a href="#__codelineno-3-11"><span class="linenos" data-linenos="11 "></span></a>sudo modprobe ip_vs
<a id="__codelineno-3-12" name="__codelineno-3-12"></a><a href="#__codelineno-3-12"><span class="linenos" data-linenos="12 "></span></a>
<a id="__codelineno-3-13" name="__codelineno-3-13"></a><a href="#__codelineno-3-13"><span class="linenos" data-linenos="13 "></span></a><span class="c1"># 再次查看会显示已加载 ip_vs 模块</span>
<a id="__codelineno-3-14" name="__codelineno-3-14"></a><a href="#__codelineno-3-14"><span class="linenos" data-linenos="14 "></span></a>sudo lsmod <span class="p">|</span> grep ip_vs
<a id="__codelineno-3-15" name="__codelineno-3-15"></a><a href="#__codelineno-3-15"><span class="linenos" data-linenos="15 "></span></a>ip_vs_sh               <span class="m">16384</span>  <span class="m">0</span>
<a id="__codelineno-3-16" name="__codelineno-3-16"></a><a href="#__codelineno-3-16"><span class="linenos" data-linenos="16 "></span></a>ip_vs_wrr              <span class="m">16384</span>  <span class="m">19</span>
<a id="__codelineno-3-17" name="__codelineno-3-17"></a><a href="#__codelineno-3-17"><span class="linenos" data-linenos="17 "></span></a>ip_vs_rr               <span class="m">16384</span>  <span class="m">0</span>
<a id="__codelineno-3-18" name="__codelineno-3-18"></a><a href="#__codelineno-3-18"><span class="linenos" data-linenos="18 "></span></a>ip_vs                 <span class="m">155648</span>  <span class="m">25</span> ip_vs_rr,ip_vs_sh,ip_vs_wrr
<a id="__codelineno-3-19" name="__codelineno-3-19"></a><a href="#__codelineno-3-19"><span class="linenos" data-linenos="19 "></span></a>nf_conntrack          <span class="m">139264</span>  <span class="m">5</span> xt_conntrack,nf_nat,nf_conntrack_netlink,xt_MASQUERADE,ip_vs
<a id="__codelineno-3-20" name="__codelineno-3-20"></a><a href="#__codelineno-3-20"><span class="linenos" data-linenos="20 "></span></a>nf_defrag_ipv6         <span class="m">24576</span>  <span class="m">2</span> nf_conntrack,ip_vs
<a id="__codelineno-3-21" name="__codelineno-3-21"></a><a href="#__codelineno-3-21"><span class="linenos" data-linenos="21 "></span></a>libcrc32c              <span class="m">16384</span>  <span class="m">3</span> nf_conntrack,nf_nat,ip_vs
</code></pre></div>
<h2 id="2-ipvs">2. 配置 IPVS<a class="headerlink" href="#2-ipvs" title="Permanent link">&para;</a></h2>
<ul>
<li>集群网络拓扑</li>
</ul>
<table>
<thead>
<tr>
<th>Host</th>
<th>eth1 (绑公网IP)</th>
<th>eth0 (绑内网IP)</th>
<th>Role</th>
<th>Services</th>
</tr>
</thead>
<tbody>
<tr>
<td>vm1</td>
<td>10.0.0.200 (模拟公网VIP)</td>
<td>10.0.0.11 (DIP)</td>
<td>DS1</td>
<td>ipvs / keepalived</td>
</tr>
<tr>
<td>vm2</td>
<td>10.0.0.200 (模拟公网VIP)</td>
<td>10.0.0.12 (DIP)</td>
<td>DS2</td>
<td>ipvs / keepalived</td>
</tr>
<tr>
<td>vm3</td>
<td>-</td>
<td>10.0.0.13 (RIP)</td>
<td>RS1</td>
<td>http.server</td>
</tr>
<tr>
<td>vm4</td>
<td>-</td>
<td>10.0.0.14 (RIP)</td>
<td>RS2</td>
<td>http.server</td>
</tr>
<tr>
<td>local</td>
<td>-</td>
<td>10.0.0.114</td>
<td>宿主机</td>
<td>-</td>
</tr>
</tbody>
</table>
<ul>
<li>说明 1：</li>
<li>
<p>以上是使用 <a href="https://www.vmware.com/">vmware</a> 或 <a href="https://www.virtualbox.org/">virtualbox</a> 模拟请求(客户端 -&gt; VIP -&gt; RIP) 过程的网络拓扑，推荐将如上<code>eth0</code> 使用<code>Bridge</code>模式（用的物理主机网卡，可与物理局域网其他物理机互通），目的是模拟外网IP要让外部客户端能访问，<code>eth1</code> 网卡使用<code>Host-Only</code>模式（其实就是<code>NAT</code>模式的特殊情况，只是没创建虚拟NAT设备让其不与外界互通），目的是模拟内网服务器不与外部互通。关于虚拟网桥、网卡、NAT设备理解请参考: <a href="https://blogs.wl4g.com/archives/2568">https://blogs.wl4g.com/archives/2568</a></p>
</li>
<li>
<p>说明 2：</p>
</li>
<li>VIP，即 <code>Virtual IP</code>，Director 用于向客户端计算机提供服务的 IP 地址，如: <code>example.com</code> 就要解析到此IP。</li>
<li>DIP，即 <code>Director IP</code>，Director 用于连接内网络的 IP 地址，绑定在另一张网卡上。DS 同理。</li>
<li>RIP，即 <code>Real IP</code>，Director 转发请求数据包到后端服务的实际 IP 地址。RS 同理。</li>
<li>CIP，即 <code>Client IP</code>，客户端 IP，请求数据包中的源 IP。</li>
</ul>
<h3 id="21-lvs-nat">2.1 配置 LVS-NAT 模式<a class="headerlink" href="#21-lvs-nat" title="Permanent link">&para;</a></h3>
<blockquote>
<p>DIP / RIP 必须在同一 LAN。</p>
</blockquote>
<p><img alt="ipvs-nat1.jpg" src="https://gitee.com/wl4g/blogs/blob/master/docs/articles/operation/ipvs-multi-mode-deploy/shots/ipvs-nat1.jpg" />，<a href="https://gitee.com/wl4g/blogs/blob/master/docs/articles/operation/ipvs-multi-mode-deploy/shots/ipvs-nat1.jpg">由于墙可移步查看</a></p>
<ul>
<li>在 vm1、vm2 上操作</li>
</ul>
<div class="highlight"><pre><span></span><code><a id="__codelineno-4-1" name="__codelineno-4-1"></a><a href="#__codelineno-4-1"><span class="linenos" data-linenos=" 1 "></span></a><span class="c1"># 先清空规则</span>
<a id="__codelineno-4-2" name="__codelineno-4-2"></a><a href="#__codelineno-4-2"><span class="linenos" data-linenos=" 2 "></span></a>sudo ipvsadm -C
<a id="__codelineno-4-3" name="__codelineno-4-3"></a><a href="#__codelineno-4-3"><span class="linenos" data-linenos=" 3 "></span></a>
<a id="__codelineno-4-4" name="__codelineno-4-4"></a><a href="#__codelineno-4-4"><span class="linenos" data-linenos=" 4 "></span></a><span class="c1"># 必须开启转发报文到别的主机，为演示简单这里使用临时生效</span>
<a id="__codelineno-4-5" name="__codelineno-4-5"></a><a href="#__codelineno-4-5"><span class="linenos" data-linenos=" 5 "></span></a><span class="nb">echo</span> <span class="m">1</span> &gt; /proc/sys/net/ipv4/ip_forward
<a id="__codelineno-4-6" name="__codelineno-4-6"></a><a href="#__codelineno-4-6"><span class="linenos" data-linenos=" 6 "></span></a>
<a id="__codelineno-4-7" name="__codelineno-4-7"></a><a href="#__codelineno-4-7"><span class="linenos" data-linenos=" 7 "></span></a><span class="c1"># 给 Director 绑定 VIP（实测发现其实只使用一张网卡 eth0 分别绑定 DIP/VIP 2个IP也可以）</span>
<a id="__codelineno-4-8" name="__codelineno-4-8"></a><a href="#__codelineno-4-8"><span class="linenos" data-linenos=" 8 "></span></a>sudo ip addr add <span class="m">10</span>.0.0.200 dev eth1
<a id="__codelineno-4-9" name="__codelineno-4-9"></a><a href="#__codelineno-4-9"><span class="linenos" data-linenos=" 9 "></span></a>
<a id="__codelineno-4-10" name="__codelineno-4-10"></a><a href="#__codelineno-4-10"><span class="linenos" data-linenos="10 "></span></a><span class="c1"># 添加一个 DR，并指定调度算法为 wrr(加权轮询)，可选: rr 、wrr 、lc 、wlc 、lblc 、lblcr 、dh 、sh 、sed 、nq</span>
<a id="__codelineno-4-11" name="__codelineno-4-11"></a><a href="#__codelineno-4-11"><span class="linenos" data-linenos="11 "></span></a>sudo ipvsadm -A -t <span class="m">10</span>.0.0.200:8080 -s wrr
<a id="__codelineno-4-12" name="__codelineno-4-12"></a><a href="#__codelineno-4-12"><span class="linenos" data-linenos="12 "></span></a>sudo ipvsadm -a -t <span class="m">10</span>.0.0.200:8080 -r <span class="m">10</span>.0.0.13 -m <span class="c1"># 添加转发到 RealServer1 的规则</span>
<a id="__codelineno-4-13" name="__codelineno-4-13"></a><a href="#__codelineno-4-13"><span class="linenos" data-linenos="13 "></span></a>sudo ipvsadm -a -t <span class="m">10</span>.0.0.200:8080 -r <span class="m">10</span>.0.0.14 -m <span class="c1"># 添加转发到 RealServer2 的规则</span>
<a id="__codelineno-4-14" name="__codelineno-4-14"></a><a href="#__codelineno-4-14"><span class="linenos" data-linenos="14 "></span></a>
<a id="__codelineno-4-15" name="__codelineno-4-15"></a><a href="#__codelineno-4-15"><span class="linenos" data-linenos="15 "></span></a><span class="c1"># 查看转发规则 (-n 表示不解析，类同 route -n 和 iptables -L -n)</span>
<a id="__codelineno-4-16" name="__codelineno-4-16"></a><a href="#__codelineno-4-16"><span class="linenos" data-linenos="16 "></span></a>sudo ipvsadm -Ln
</code></pre></div>
<ul>
<li>在 vm3、vm4 上操作</li>
</ul>
<div class="highlight"><pre><span></span><code><a id="__codelineno-5-1" name="__codelineno-5-1"></a><a href="#__codelineno-5-1"><span class="linenos" data-linenos="1 "></span></a><span class="c1"># 必须将 eth0 的网关设置为 DIP（与 DR 模式相反），这也是 NAT 模式精华所在</span>
<a id="__codelineno-5-2" name="__codelineno-5-2"></a><a href="#__codelineno-5-2"><span class="linenos" data-linenos="2 "></span></a>sudo sed -i -r <span class="s1">&#39;s/^GATEWAY(.*)=.*/GATEWAY=10.0.0.11/g&#39;</span> /etc/sysconfig/network-scripts/ifcfg-eth0
<a id="__codelineno-5-3" name="__codelineno-5-3"></a><a href="#__codelineno-5-3"><span class="linenos" data-linenos="3 "></span></a>
<a id="__codelineno-5-4" name="__codelineno-5-4"></a><a href="#__codelineno-5-4"><span class="linenos" data-linenos="4 "></span></a><span class="c1"># 重启</span>
<a id="__codelineno-5-5" name="__codelineno-5-5"></a><a href="#__codelineno-5-5"><span class="linenos" data-linenos="5 "></span></a>sudo systemctl restart network
<a id="__codelineno-5-6" name="__codelineno-5-6"></a><a href="#__codelineno-5-6"><span class="linenos" data-linenos="6 "></span></a>
<a id="__codelineno-5-7" name="__codelineno-5-7"></a><a href="#__codelineno-5-7"><span class="linenos" data-linenos="7 "></span></a><span class="c1"># 如果是 ubuntu18+ 则是修改: /etc/netplan/01-network-manager-all.yaml</span>
<a id="__codelineno-5-8" name="__codelineno-5-8"></a><a href="#__codelineno-5-8"><span class="linenos" data-linenos="8 "></span></a><span class="c1"># 重启: sudo netplan --debug apply</span>
</code></pre></div>
<blockquote>
<p>其中 <code>-m</code> 即: <code>--masquerading</code> NAT 模式</p>
</blockquote>
<ul>
<li>
<p><a href="https://www.zsythink.net/archives/1663">关于 ip_forward 相关设置</a></p>
</li>
<li>
<p>准备测试 (分别在 vm3、vm4 启动测试 http.server)</p>
</li>
</ul>
<div class="highlight"><pre><span></span><code><a id="__codelineno-6-1" name="__codelineno-6-1"></a><a href="#__codelineno-6-1"><span class="linenos" data-linenos="1 "></span></a><span class="c1"># vm3 上执行</span>
<a id="__codelineno-6-2" name="__codelineno-6-2"></a><a href="#__codelineno-6-2"><span class="linenos" data-linenos="2 "></span></a>mkdir -p /tmp/test/
<a id="__codelineno-6-3" name="__codelineno-6-3"></a><a href="#__codelineno-6-3"><span class="linenos" data-linenos="3 "></span></a>touch /tmp/test/my-vm3.txt
<a id="__codelineno-6-4" name="__codelineno-6-4"></a><a href="#__codelineno-6-4"><span class="linenos" data-linenos="4 "></span></a>python3 -m http.server --directory /tmp/test/
<a id="__codelineno-6-5" name="__codelineno-6-5"></a><a href="#__codelineno-6-5"><span class="linenos" data-linenos="5 "></span></a>
<a id="__codelineno-6-6" name="__codelineno-6-6"></a><a href="#__codelineno-6-6"><span class="linenos" data-linenos="6 "></span></a><span class="c1"># vm4 上执行</span>
<a id="__codelineno-6-7" name="__codelineno-6-7"></a><a href="#__codelineno-6-7"><span class="linenos" data-linenos="7 "></span></a>mkdir -p /tmp/test/
<a id="__codelineno-6-8" name="__codelineno-6-8"></a><a href="#__codelineno-6-8"><span class="linenos" data-linenos="8 "></span></a>touch /tmp/test/my-vm4.txt
<a id="__codelineno-6-9" name="__codelineno-6-9"></a><a href="#__codelineno-6-9"><span class="linenos" data-linenos="9 "></span></a>python3 -m http.server --directory /tmp/test/
</code></pre></div>
<ul>
<li>在物理机(10.0.0.114)上访问 VIP，模拟外网客户端请求</li>
</ul>
<div class="highlight"><pre><span></span><code><a id="__codelineno-7-1" name="__codelineno-7-1"></a><a href="#__codelineno-7-1"><span class="linenos" data-linenos="1 "></span></a><span class="k">for</span> i <span class="k">in</span> <span class="sb">`</span>seq <span class="m">1</span> <span class="m">10</span><span class="sb">`</span><span class="p">;</span> <span class="k">do</span> curl -s <span class="m">10</span>.0.0.200:8080 <span class="p">|</span> grep txt<span class="p">;</span> <span class="k">done</span>
<a id="__codelineno-7-2" name="__codelineno-7-2"></a><a href="#__codelineno-7-2"><span class="linenos" data-linenos="2 "></span></a>&lt;li&gt;&lt;a <span class="nv">href</span><span class="o">=</span><span class="s2">&quot;vm3.txt&quot;</span>&gt;vm3.txt&lt;/a&gt;&lt;/li&gt;
<a id="__codelineno-7-3" name="__codelineno-7-3"></a><a href="#__codelineno-7-3"><span class="linenos" data-linenos="3 "></span></a>&lt;li&gt;&lt;a <span class="nv">href</span><span class="o">=</span><span class="s2">&quot;vm4.txt&quot;</span>&gt;vm4.txt&lt;/a&gt;&lt;/li&gt;
<a id="__codelineno-7-4" name="__codelineno-7-4"></a><a href="#__codelineno-7-4"><span class="linenos" data-linenos="4 "></span></a>&lt;li&gt;&lt;a <span class="nv">href</span><span class="o">=</span><span class="s2">&quot;vm3.txt&quot;</span>&gt;vm3.txt&lt;/a&gt;&lt;/li&gt;
<a id="__codelineno-7-5" name="__codelineno-7-5"></a><a href="#__codelineno-7-5"><span class="linenos" data-linenos="5 "></span></a>&lt;li&gt;&lt;a <span class="nv">href</span><span class="o">=</span><span class="s2">&quot;vm4.txt&quot;</span>&gt;vm4.txt&lt;/a&gt;&lt;/li&gt;
<a id="__codelineno-7-6" name="__codelineno-7-6"></a><a href="#__codelineno-7-6"><span class="linenos" data-linenos="6 "></span></a>...
</code></pre></div>
<h3 id="22-lvs-dr">2.2 配置 LVS-DR 模式<a class="headerlink" href="#22-lvs-dr" title="Permanent link">&para;</a></h3>
<blockquote>
<p>注：与 NAT 模式相反，必须不能设置 RS 的 gateway 为 DIP。
本节实验条件为：VIP / DIP / RIP 在同一 LAN，这样比较简单，无需额外路由配置（不同网段也可以，只需加对路由即可）。</p>
</blockquote>
<p><img alt="ipvs-dr1.jpg" src="https://gitee.com/wl4g/blogs/blob/master/docs/articles/operation/ipvs-multi-mode-deploy/shots/ipvs-dr1.jpg" />，<a href="https://gitee.com/wl4g/blogs/blob/master/docs/articles/operation/ipvs-multi-mode-deploy/shots/ipvs-dr1.jpg">由于墙可移步查看</a></p>
<ul>
<li>在 vm1、vm2 上操作</li>
</ul>
<div class="highlight"><pre><span></span><code><a id="__codelineno-8-1" name="__codelineno-8-1"></a><a href="#__codelineno-8-1"><span class="linenos" data-linenos=" 1 "></span></a><span class="c1"># 先清空规则</span>
<a id="__codelineno-8-2" name="__codelineno-8-2"></a><a href="#__codelineno-8-2"><span class="linenos" data-linenos=" 2 "></span></a>sudo ipvsadm -C
<a id="__codelineno-8-3" name="__codelineno-8-3"></a><a href="#__codelineno-8-3"><span class="linenos" data-linenos=" 3 "></span></a>
<a id="__codelineno-8-4" name="__codelineno-8-4"></a><a href="#__codelineno-8-4"><span class="linenos" data-linenos=" 4 "></span></a><span class="c1"># 必须开启转发报文到别的主机，为演示简单这里使用临时生效</span>
<a id="__codelineno-8-5" name="__codelineno-8-5"></a><a href="#__codelineno-8-5"><span class="linenos" data-linenos=" 5 "></span></a><span class="nb">echo</span> <span class="m">1</span> &gt; /proc/sys/net/ipv4/ip_forward
<a id="__codelineno-8-6" name="__codelineno-8-6"></a><a href="#__codelineno-8-6"><span class="linenos" data-linenos=" 6 "></span></a>
<a id="__codelineno-8-7" name="__codelineno-8-7"></a><a href="#__codelineno-8-7"><span class="linenos" data-linenos=" 7 "></span></a><span class="c1"># 给 Director 绑定 VIP（实测发现其实只使用一张网卡 eth0 分别绑定 DIP/VIP 2个IP也可以）</span>
<a id="__codelineno-8-8" name="__codelineno-8-8"></a><a href="#__codelineno-8-8"><span class="linenos" data-linenos=" 8 "></span></a>sudo ip addr add <span class="m">10</span>.0.0.200 dev eth1
<a id="__codelineno-8-9" name="__codelineno-8-9"></a><a href="#__codelineno-8-9"><span class="linenos" data-linenos=" 9 "></span></a>
<a id="__codelineno-8-10" name="__codelineno-8-10"></a><a href="#__codelineno-8-10"><span class="linenos" data-linenos="10 "></span></a><span class="c1"># 添加一个 DR，并指定调度算法为 wrr(加权轮询)，可选: rr 、wrr 、lc 、wlc 、lblc 、lblcr 、dh 、sh 、sed 、nq</span>
<a id="__codelineno-8-11" name="__codelineno-8-11"></a><a href="#__codelineno-8-11"><span class="linenos" data-linenos="11 "></span></a>sudo ipvsadm -A -t <span class="m">10</span>.0.0.200:8080 -s wrr
<a id="__codelineno-8-12" name="__codelineno-8-12"></a><a href="#__codelineno-8-12"><span class="linenos" data-linenos="12 "></span></a>sudo ipvsadm -a -t <span class="m">10</span>.0.0.200:8080 -r <span class="m">10</span>.0.0.13 -g <span class="c1"># 添加转发到 RealServer1 的规则</span>
<a id="__codelineno-8-13" name="__codelineno-8-13"></a><a href="#__codelineno-8-13"><span class="linenos" data-linenos="13 "></span></a>sudo ipvsadm -a -t <span class="m">10</span>.0.0.200:8080 -r <span class="m">10</span>.0.0.14 -g <span class="c1"># 添加转发到 RealServer2 的规则</span>
<a id="__codelineno-8-14" name="__codelineno-8-14"></a><a href="#__codelineno-8-14"><span class="linenos" data-linenos="14 "></span></a>
<a id="__codelineno-8-15" name="__codelineno-8-15"></a><a href="#__codelineno-8-15"><span class="linenos" data-linenos="15 "></span></a><span class="c1"># 查看转发规则 (-n 表示不解析，类同 route -n 和 iptables -L -n)</span>
<a id="__codelineno-8-16" name="__codelineno-8-16"></a><a href="#__codelineno-8-16"><span class="linenos" data-linenos="16 "></span></a>sudo ipvsadm -Ln
</code></pre></div>
<ul>
<li>在 vm3、vm4 上操作</li>
</ul>
<div class="highlight"><pre><span></span><code><a id="__codelineno-9-1" name="__codelineno-9-1"></a><a href="#__codelineno-9-1"><span class="linenos" data-linenos=" 1 "></span></a><span class="c1"># 首先，必须要还原网关配置（与 NAT 模式相反）</span>
<a id="__codelineno-9-2" name="__codelineno-9-2"></a><a href="#__codelineno-9-2"><span class="linenos" data-linenos=" 2 "></span></a>sudo sed -i -r <span class="s1">&#39;s/^GATEWAY(.*)=.*/GATEWAY=10.0.0.1/g&#39;</span> /etc/sysconfig/network-scripts/ifcfg-eth0
<a id="__codelineno-9-3" name="__codelineno-9-3"></a><a href="#__codelineno-9-3"><span class="linenos" data-linenos=" 3 "></span></a>sudo systemctl restart network
<a id="__codelineno-9-4" name="__codelineno-9-4"></a><a href="#__codelineno-9-4"><span class="linenos" data-linenos=" 4 "></span></a>
<a id="__codelineno-9-5" name="__codelineno-9-5"></a><a href="#__codelineno-9-5"><span class="linenos" data-linenos=" 5 "></span></a><span class="c1"># 必须禁用 arp 响应</span>
<a id="__codelineno-9-6" name="__codelineno-9-6"></a><a href="#__codelineno-9-6"><span class="linenos" data-linenos=" 6 "></span></a><span class="c1"># 原因：路由表根据 arp 表项，会将新来的请求报文转发给RealServer，导致Director的VIP失效，使系统不使用IP包的源地址来设置 arp 请求的源地址，而选择发送接口的IP地址</span>
<a id="__codelineno-9-7" name="__codelineno-9-7"></a><a href="#__codelineno-9-7"><span class="linenos" data-linenos=" 7 "></span></a>sudo <span class="nb">echo</span> <span class="s2">&quot;1&quot;</span> &gt; /proc/sys/net/ipv4/conf/lo/arp_ignore
<a id="__codelineno-9-8" name="__codelineno-9-8"></a><a href="#__codelineno-9-8"><span class="linenos" data-linenos=" 8 "></span></a>sudo <span class="nb">echo</span> <span class="s2">&quot;1&quot;</span> &gt; /proc/sys/net/ipv4/conf/all/arp_ignore
<a id="__codelineno-9-9" name="__codelineno-9-9"></a><a href="#__codelineno-9-9"><span class="linenos" data-linenos=" 9 "></span></a>sudo <span class="nb">echo</span> <span class="s2">&quot;2&quot;</span> &gt; /proc/sys/net/ipv4/conf/lo/arp_announce
<a id="__codelineno-9-10" name="__codelineno-9-10"></a><a href="#__codelineno-9-10"><span class="linenos" data-linenos="10 "></span></a>sudo <span class="nb">echo</span> <span class="s2">&quot;2&quot;</span> &gt; /proc/sys/net/ipv4/conf/all/arp_announce
<a id="__codelineno-9-11" name="__codelineno-9-11"></a><a href="#__codelineno-9-11"><span class="linenos" data-linenos="11 "></span></a>
<a id="__codelineno-9-12" name="__codelineno-9-12"></a><a href="#__codelineno-9-12"><span class="linenos" data-linenos="12 "></span></a><span class="c1"># 必须绑定 VIP 到 lo，这是为了让回包时的 SIP = VIP，这就是 DR 模式的精华所在</span>
<a id="__codelineno-9-13" name="__codelineno-9-13"></a><a href="#__codelineno-9-13"><span class="linenos" data-linenos="13 "></span></a>sudo ip addr add <span class="m">10</span>.0.0.200 dev lo
<a id="__codelineno-9-14" name="__codelineno-9-14"></a><a href="#__codelineno-9-14"><span class="linenos" data-linenos="14 "></span></a>
<a id="__codelineno-9-15" name="__codelineno-9-15"></a><a href="#__codelineno-9-15"><span class="linenos" data-linenos="15 "></span></a><span class="c1"># 必须让 RS 回包走 lo 接口，这样才能使 SIP = VIP</span>
<a id="__codelineno-9-16" name="__codelineno-9-16"></a><a href="#__codelineno-9-16"><span class="linenos" data-linenos="16 "></span></a>sudo ip route add <span class="m">10</span>.0.0.200 dev lo
</code></pre></div>
<ul>
<li>准备测试 (分别在 vm3、vm4 启动测试 http.server)</li>
</ul>
<div class="highlight"><pre><span></span><code><a id="__codelineno-10-1" name="__codelineno-10-1"></a><a href="#__codelineno-10-1"><span class="linenos" data-linenos="1 "></span></a><span class="c1"># vm3 上执行</span>
<a id="__codelineno-10-2" name="__codelineno-10-2"></a><a href="#__codelineno-10-2"><span class="linenos" data-linenos="2 "></span></a>mkdir -p /tmp/test/
<a id="__codelineno-10-3" name="__codelineno-10-3"></a><a href="#__codelineno-10-3"><span class="linenos" data-linenos="3 "></span></a>touch /tmp/test/my-vm3.txt
<a id="__codelineno-10-4" name="__codelineno-10-4"></a><a href="#__codelineno-10-4"><span class="linenos" data-linenos="4 "></span></a>python3 -m http.server <span class="m">8080</span> --directory /tmp/test/
<a id="__codelineno-10-5" name="__codelineno-10-5"></a><a href="#__codelineno-10-5"><span class="linenos" data-linenos="5 "></span></a>
<a id="__codelineno-10-6" name="__codelineno-10-6"></a><a href="#__codelineno-10-6"><span class="linenos" data-linenos="6 "></span></a><span class="c1"># vm4 上执行</span>
<a id="__codelineno-10-7" name="__codelineno-10-7"></a><a href="#__codelineno-10-7"><span class="linenos" data-linenos="7 "></span></a>mkdir -p /tmp/test/
<a id="__codelineno-10-8" name="__codelineno-10-8"></a><a href="#__codelineno-10-8"><span class="linenos" data-linenos="8 "></span></a>touch /tmp/test/my-vm4.txt
<a id="__codelineno-10-9" name="__codelineno-10-9"></a><a href="#__codelineno-10-9"><span class="linenos" data-linenos="9 "></span></a>python3 -m http.server <span class="m">8080</span> --directory /tmp/test/
</code></pre></div>
<ul>
<li>在物理机(10.0.0.114)上访问 VIP，模拟外网客户端请求</li>
</ul>
<div class="highlight"><pre><span></span><code><a id="__codelineno-11-1" name="__codelineno-11-1"></a><a href="#__codelineno-11-1"><span class="linenos" data-linenos="1 "></span></a><span class="k">for</span> i <span class="k">in</span> <span class="sb">`</span>seq <span class="m">1</span> <span class="m">10</span><span class="sb">`</span><span class="p">;</span> <span class="k">do</span> curl -s <span class="m">10</span>.0.0.200:8080 <span class="p">|</span> grep txt<span class="p">;</span> <span class="k">done</span>
<a id="__codelineno-11-2" name="__codelineno-11-2"></a><a href="#__codelineno-11-2"><span class="linenos" data-linenos="2 "></span></a>&lt;li&gt;&lt;a <span class="nv">href</span><span class="o">=</span><span class="s2">&quot;vm3.txt&quot;</span>&gt;vm3.txt&lt;/a&gt;&lt;/li&gt;
<a id="__codelineno-11-3" name="__codelineno-11-3"></a><a href="#__codelineno-11-3"><span class="linenos" data-linenos="3 "></span></a>&lt;li&gt;&lt;a <span class="nv">href</span><span class="o">=</span><span class="s2">&quot;vm4.txt&quot;</span>&gt;vm4.txt&lt;/a&gt;&lt;/li&gt;
<a id="__codelineno-11-4" name="__codelineno-11-4"></a><a href="#__codelineno-11-4"><span class="linenos" data-linenos="4 "></span></a>&lt;li&gt;&lt;a <span class="nv">href</span><span class="o">=</span><span class="s2">&quot;vm3.txt&quot;</span>&gt;vm3.txt&lt;/a&gt;&lt;/li&gt;
<a id="__codelineno-11-5" name="__codelineno-11-5"></a><a href="#__codelineno-11-5"><span class="linenos" data-linenos="5 "></span></a>&lt;li&gt;&lt;a <span class="nv">href</span><span class="o">=</span><span class="s2">&quot;vm4.txt&quot;</span>&gt;vm4.txt&lt;/a&gt;&lt;/li&gt;
<a id="__codelineno-11-6" name="__codelineno-11-6"></a><a href="#__codelineno-11-6"><span class="linenos" data-linenos="6 "></span></a>...
</code></pre></div>
<blockquote>
<p>其中 <code>-g</code> 即: <code>--gatewaying</code> direct routing 模式</p>
<p><strong><em>注：</em></strong> 实测发现，只能在 Director 机以外的其他机器上请求 VIP 才通？ 分析参见：<a href="#5.1">#5.1</a></p>
</blockquote>
<h2 id="3">3. 备份还原<a class="headerlink" href="#3" title="Permanent link">&para;</a></h2>
<div class="highlight"><pre><span></span><code><a id="__codelineno-12-1" name="__codelineno-12-1"></a><a href="#__codelineno-12-1"><span class="linenos" data-linenos="1 "></span></a><span class="c1"># 备份规则</span>
<a id="__codelineno-12-2" name="__codelineno-12-2"></a><a href="#__codelineno-12-2"><span class="linenos" data-linenos="2 "></span></a>sudo ipvsadm -S &gt; ipvs.rule.bak1
<a id="__codelineno-12-3" name="__codelineno-12-3"></a><a href="#__codelineno-12-3"><span class="linenos" data-linenos="3 "></span></a>
<a id="__codelineno-12-4" name="__codelineno-12-4"></a><a href="#__codelineno-12-4"><span class="linenos" data-linenos="4 "></span></a><span class="c1"># 还原规则</span>
<a id="__codelineno-12-5" name="__codelineno-12-5"></a><a href="#__codelineno-12-5"><span class="linenos" data-linenos="5 "></span></a>sudo ipvsadm -R &lt; ipvs.rule.bak1
</code></pre></div>
<h2 id="4-keepalived-ha">4. 部署 keepalived (实现 HA)<a class="headerlink" href="#4-keepalived-ha" title="Permanent link">&para;</a></h2>
<blockquote>
<p><strong><em>注：</em></strong> 虽然可以使用 keepalived 自动选举 ipvs 的 active 节点 (绑定 VIP) 来实现 HA，其相当于 k8s 中 metalLB 的 Layer2 模式，即主备模式，也即集中式负载均衡架构，始终只有一个节点转发流量并非真正意义的 HA，更优雅的做法应该是如 metalLB 的 BGP 模式，即分布式负载均衡架构，它可从外部网络 (客户端网络或互联网) 最早就可将数据包分流到各地域的服务器网关，相关技术有 AnyCast BGP。</p>
</blockquote>
<ul>
<li>请参见: <a href="https://blogs.wl4g.com/archives/743">MYSQL MGR + KEEPALIVED + HAPROXY 高可用企业级生产部署</a></li>
</ul>
<h2 id="5-faq">5. FAQ<a class="headerlink" href="#5-faq" title="Permanent link">&para;</a></h2>
<h3 id="51-director-vip">5.1 在 Director 机上请求 VIP 不通卡死？<a class="headerlink" href="#51-director-vip" title="Permanent link">&para;</a></h3>
<ul>
<li>
<p>现象：实测发现，不能在 Director 机上请求 VIP (即在 10.0.0.11 上执行 curl -v 10.0.0.200) 会卡死。</p>
</li>
<li>
<p>分析：分别在 Director 和 RS 上执行 <code>tcpdump -i any dst 10.0.0.200 or dst 10.0.0.200</code> 捕获会发现，请求已经到达了 RS ，但是响应没有成功，初步分析应该是跟 arp 有关，也可以侧证通过在 Director 机上执行 <code>arping 10.0.0.200</code> 和在 RS 上执行，前者会 Timeout 但后者能响应，响应的 MAC 就是 Director 的地址。</p>
</li>
</ul>
<h3 id="52-tcpdump-dr">5.2 实测使用 tcpdump 抓包原理分析(DR模式)<a class="headerlink" href="#52-tcpdump-dr" title="Permanent link">&para;</a></h3>
<ul>
<li>在物理机(10.0.0.114)抓包</li>
</ul>
<div class="highlight"><pre><span></span><code><a id="__codelineno-13-1" name="__codelineno-13-1"></a><a href="#__codelineno-13-1"><span class="linenos" data-linenos=" 1 "></span></a>jameswrong@jameswrong-pro:~$ sudo tcpdump -i any dst port <span class="m">8080</span> or src port <span class="m">8080</span>
<a id="__codelineno-13-2" name="__codelineno-13-2"></a><a href="#__codelineno-13-2"><span class="linenos" data-linenos=" 2 "></span></a>
<a id="__codelineno-13-3" name="__codelineno-13-3"></a><a href="#__codelineno-13-3"><span class="linenos" data-linenos=" 3 "></span></a>tcpdump: verbose output suppressed, use -v or -vv <span class="k">for</span> full protocol decode
<a id="__codelineno-13-4" name="__codelineno-13-4"></a><a href="#__codelineno-13-4"><span class="linenos" data-linenos=" 4 "></span></a>listening on any, link-type LINUX_SLL <span class="o">(</span>Linux cooked v1<span class="o">)</span>, capture size <span class="m">262144</span> bytes
<a id="__codelineno-13-5" name="__codelineno-13-5"></a><a href="#__codelineno-13-5"><span class="linenos" data-linenos=" 5 "></span></a><span class="m">13</span>:16:00.883659 IP <span class="m">10</span>.0.0.114.37644 &gt; <span class="m">10</span>.0.0.200.http-alt: Flags <span class="o">[</span>S<span class="o">]</span>, seq <span class="m">2149029805</span>, win <span class="m">64240</span>, options <span class="o">[</span>mss <span class="m">1460</span>,sackOK,TS val <span class="m">1594908454</span> ecr <span class="m">0</span>,nop,wscale <span class="m">7</span><span class="o">]</span>, length <span class="m">0</span>
<a id="__codelineno-13-6" name="__codelineno-13-6"></a><a href="#__codelineno-13-6"><span class="linenos" data-linenos=" 6 "></span></a><span class="m">13</span>:16:00.884602 IP <span class="m">10</span>.0.0.200.http-alt &gt; <span class="m">10</span>.0.0.114.37644: Flags <span class="o">[</span>S.<span class="o">]</span>, seq <span class="m">4132810452</span>, ack <span class="m">2149029806</span>, win <span class="m">65160</span>, options <span class="o">[</span>mss <span class="m">1460</span>,sackOK,TS val <span class="m">11697075</span> ecr <span class="m">1594908454</span>,nop,wscale <span class="m">7</span><span class="o">]</span>, length <span class="m">0</span>
<a id="__codelineno-13-7" name="__codelineno-13-7"></a><a href="#__codelineno-13-7"><span class="linenos" data-linenos=" 7 "></span></a><span class="m">13</span>:16:00.884714 IP <span class="m">10</span>.0.0.114.37644 &gt; <span class="m">10</span>.0.0.200.http-alt: Flags <span class="o">[</span>.<span class="o">]</span>, ack <span class="m">1</span>, win <span class="m">502</span>, options <span class="o">[</span>nop,nop,TS val <span class="m">1594908455</span> ecr <span class="m">11697075</span><span class="o">]</span>, length <span class="m">0</span>
<a id="__codelineno-13-8" name="__codelineno-13-8"></a><a href="#__codelineno-13-8"><span class="linenos" data-linenos=" 8 "></span></a><span class="m">13</span>:16:00.884881 IP <span class="m">10</span>.0.0.114.37644 &gt; <span class="m">10</span>.0.0.200.http-alt: Flags <span class="o">[</span>P.<span class="o">]</span>, seq <span class="m">1</span>:83, ack <span class="m">1</span>, win <span class="m">502</span>, options <span class="o">[</span>nop,nop,TS val <span class="m">1594908455</span> ecr <span class="m">11697075</span><span class="o">]</span>, length <span class="m">82</span>: HTTP: GET / HTTP/1.1
<a id="__codelineno-13-9" name="__codelineno-13-9"></a><a href="#__codelineno-13-9"><span class="linenos" data-linenos=" 9 "></span></a><span class="m">13</span>:16:00.885377 IP <span class="m">10</span>.0.0.200.http-alt &gt; <span class="m">10</span>.0.0.114.37644: Flags <span class="o">[</span>.<span class="o">]</span>, ack <span class="m">83</span>, win <span class="m">509</span>, options <span class="o">[</span>nop,nop,TS val <span class="m">11697076</span> ecr <span class="m">1594908455</span><span class="o">]</span>, length <span class="m">0</span>
<a id="__codelineno-13-10" name="__codelineno-13-10"></a><a href="#__codelineno-13-10"><span class="linenos" data-linenos="10 "></span></a><span class="m">13</span>:16:00.889646 IP <span class="m">10</span>.0.0.200.http-alt &gt; <span class="m">10</span>.0.0.114.37644: Flags <span class="o">[</span>P.<span class="o">]</span>, seq <span class="m">1</span>:186, ack <span class="m">83</span>, win <span class="m">509</span>, options <span class="o">[</span>nop,nop,TS val <span class="m">11697080</span> ecr <span class="m">1594908455</span><span class="o">]</span>, length <span class="m">185</span>: HTTP: HTTP/1.0 <span class="m">404</span> File not found
<a id="__codelineno-13-11" name="__codelineno-13-11"></a><a href="#__codelineno-13-11"><span class="linenos" data-linenos="11 "></span></a><span class="m">13</span>:16:00.889686 IP <span class="m">10</span>.0.0.114.37644 &gt; <span class="m">10</span>.0.0.200.http-alt: Flags <span class="o">[</span>.<span class="o">]</span>, ack <span class="m">186</span>, win <span class="m">501</span>, options <span class="o">[</span>nop,nop,TS val <span class="m">1594908460</span> ecr <span class="m">11697080</span><span class="o">]</span>, length <span class="m">0</span>
<a id="__codelineno-13-12" name="__codelineno-13-12"></a><a href="#__codelineno-13-12"><span class="linenos" data-linenos="12 "></span></a><span class="m">13</span>:16:00.889861 IP <span class="m">10</span>.0.0.200.http-alt &gt; <span class="m">10</span>.0.0.114.37644: Flags <span class="o">[</span>FP.<span class="o">]</span>, seq <span class="m">186</span>:655, ack <span class="m">83</span>, win <span class="m">509</span>, options <span class="o">[</span>nop,nop,TS val <span class="m">11697080</span> ecr <span class="m">1594908455</span><span class="o">]</span>, length <span class="m">469</span>: HTTP
</code></pre></div>
<ul>
<li>在 DS2 (10.0.0.12) 上同一时刻抓包输出如下</li>
</ul>
<div class="highlight"><pre><span></span><code><a id="__codelineno-14-1" name="__codelineno-14-1"></a><a href="#__codelineno-14-1"><span class="linenos" data-linenos=" 1 "></span></a>root@lvs-ds2:~# sudo tcpdump -i any dst port <span class="m">8080</span> or src port <span class="m">8080</span>
<a id="__codelineno-14-2" name="__codelineno-14-2"></a><a href="#__codelineno-14-2"><span class="linenos" data-linenos=" 2 "></span></a>
<a id="__codelineno-14-3" name="__codelineno-14-3"></a><a href="#__codelineno-14-3"><span class="linenos" data-linenos=" 3 "></span></a>tcpdump: verbose output suppressed, use -v or -vv <span class="k">for</span> full protocol decode
<a id="__codelineno-14-4" name="__codelineno-14-4"></a><a href="#__codelineno-14-4"><span class="linenos" data-linenos=" 4 "></span></a>listening on any, link-type LINUX_SLL <span class="o">(</span>Linux cooked v1<span class="o">)</span>, capture size <span class="m">262144</span> bytes
<a id="__codelineno-14-5" name="__codelineno-14-5"></a><a href="#__codelineno-14-5"><span class="linenos" data-linenos=" 5 "></span></a><span class="m">13</span>:16:00.845812 IP <span class="m">10</span>.0.0.114.37644 &gt; lvs-ds2.http-alt: Flags <span class="o">[</span>S<span class="o">]</span>, seq <span class="m">2149029805</span>, win <span class="m">64240</span>, options <span class="o">[</span>mss <span class="m">1460</span>,sackOK,TS val <span class="m">1594908454</span> ecr <span class="m">0</span>,nop,wscale <span class="m">7</span><span class="o">]</span>, length <span class="m">0</span>
<a id="__codelineno-14-6" name="__codelineno-14-6"></a><a href="#__codelineno-14-6"><span class="linenos" data-linenos=" 6 "></span></a><span class="m">13</span>:16:00.845907 IP <span class="m">10</span>.0.0.114.37644 &gt; lvs-ds2.http-alt: Flags <span class="o">[</span>S<span class="o">]</span>, seq <span class="m">2149029805</span>, win <span class="m">64240</span>, options <span class="o">[</span>mss <span class="m">1460</span>,sackOK,TS val <span class="m">1594908454</span> ecr <span class="m">0</span>,nop,wscale <span class="m">7</span><span class="o">]</span>, length <span class="m">0</span>
<a id="__codelineno-14-7" name="__codelineno-14-7"></a><a href="#__codelineno-14-7"><span class="linenos" data-linenos=" 7 "></span></a><span class="m">13</span>:16:00.846756 IP <span class="m">10</span>.0.0.114.37644 &gt; lvs-ds2.http-alt: Flags <span class="o">[</span>.<span class="o">]</span>, ack <span class="m">4132810453</span>, win <span class="m">502</span>, options <span class="o">[</span>nop,nop,TS val <span class="m">1594908455</span> ecr <span class="m">11697075</span><span class="o">]</span>, length <span class="m">0</span>
<a id="__codelineno-14-8" name="__codelineno-14-8"></a><a href="#__codelineno-14-8"><span class="linenos" data-linenos=" 8 "></span></a><span class="m">13</span>:16:00.846757 IP <span class="m">10</span>.0.0.114.37644 &gt; lvs-ds2.http-alt: Flags <span class="o">[</span>P.<span class="o">]</span>, seq <span class="m">0</span>:82, ack <span class="m">1</span>, win <span class="m">502</span>, options <span class="o">[</span>nop,nop,TS val <span class="m">1594908455</span> ecr <span class="m">11697075</span><span class="o">]</span>, length <span class="m">82</span>: HTTP: GET / HTTP/1.1
<a id="__codelineno-14-9" name="__codelineno-14-9"></a><a href="#__codelineno-14-9"><span class="linenos" data-linenos=" 9 "></span></a><span class="m">13</span>:16:00.846810 IP <span class="m">10</span>.0.0.114.37644 &gt; lvs-ds2.http-alt: Flags <span class="o">[</span>.<span class="o">]</span>, ack <span class="m">1</span>, win <span class="m">502</span>, options <span class="o">[</span>nop,nop,TS val <span class="m">1594908455</span> ecr <span class="m">11697075</span><span class="o">]</span>, length <span class="m">0</span>
<a id="__codelineno-14-10" name="__codelineno-14-10"></a><a href="#__codelineno-14-10"><span class="linenos" data-linenos="10 "></span></a><span class="m">13</span>:16:00.846851 IP <span class="m">10</span>.0.0.114.37644 &gt; lvs-ds2.http-alt: Flags <span class="o">[</span>P.<span class="o">]</span>, seq <span class="m">0</span>:82, ack <span class="m">1</span>, win <span class="m">502</span>, options <span class="o">[</span>nop,nop,TS val <span class="m">1594908455</span> ecr <span class="m">11697075</span><span class="o">]</span>, length <span class="m">82</span>: HTTP: GET / HTTP/1.1
<a id="__codelineno-14-11" name="__codelineno-14-11"></a><a href="#__codelineno-14-11"><span class="linenos" data-linenos="11 "></span></a><span class="m">13</span>:16:00.851738 IP <span class="m">10</span>.0.0.114.37644 &gt; lvs-ds2.http-alt: Flags <span class="o">[</span>.<span class="o">]</span>, ack <span class="m">186</span>, win <span class="m">501</span>, options <span class="o">[</span>nop,nop,TS val <span class="m">1594908460</span> ecr <span class="m">11697080</span><span class="o">]</span>, length <span class="m">0</span>
<a id="__codelineno-14-12" name="__codelineno-14-12"></a><a href="#__codelineno-14-12"><span class="linenos" data-linenos="12 "></span></a><span class="m">13</span>:16:00.851799 IP <span class="m">10</span>.0.0.114.37644 &gt; lvs-ds2.http-alt: Flags <span class="o">[</span>.<span class="o">]</span>, ack <span class="m">186</span>, win <span class="m">501</span>, options <span class="o">[</span>nop,nop,TS val <span class="m">1594908460</span> ecr <span class="m">11697080</span><span class="o">]</span>, length <span class="m">0</span>
</code></pre></div>
<ul>
<li>在 RS1 (10.0.0.13) 上同一时刻抓包输出如下</li>
</ul>
<div class="highlight"><pre><span></span><code><a id="__codelineno-15-1" name="__codelineno-15-1"></a><a href="#__codelineno-15-1"><span class="linenos" data-linenos=" 1 "></span></a>root@lvs-rs1:~# sudo tcpdump -i any dst port <span class="m">8080</span> or src port <span class="m">8080</span>
<a id="__codelineno-15-2" name="__codelineno-15-2"></a><a href="#__codelineno-15-2"><span class="linenos" data-linenos=" 2 "></span></a>
<a id="__codelineno-15-3" name="__codelineno-15-3"></a><a href="#__codelineno-15-3"><span class="linenos" data-linenos=" 3 "></span></a>tcpdump: verbose output suppressed, use -v or -vv <span class="k">for</span> full protocol decode
<a id="__codelineno-15-4" name="__codelineno-15-4"></a><a href="#__codelineno-15-4"><span class="linenos" data-linenos=" 4 "></span></a>listening on any, link-type LINUX_SLL <span class="o">(</span>Linux cooked v1<span class="o">)</span>, capture size <span class="m">262144</span> bytes
<a id="__codelineno-15-5" name="__codelineno-15-5"></a><a href="#__codelineno-15-5"><span class="linenos" data-linenos=" 5 "></span></a><span class="m">13</span>:16:00.822295 IP <span class="m">10</span>.0.0.114.37644 &gt; lvs-rs1.http-alt: Flags <span class="o">[</span>S<span class="o">]</span>, seq <span class="m">2149029805</span>, win <span class="m">64240</span>, options <span class="o">[</span>mss <span class="m">1460</span>,sackOK,TS val <span class="m">1594908454</span> ecr <span class="m">0</span>,nop,wscale <span class="m">7</span><span class="o">]</span>, length <span class="m">0</span>
<a id="__codelineno-15-6" name="__codelineno-15-6"></a><a href="#__codelineno-15-6"><span class="linenos" data-linenos=" 6 "></span></a><span class="m">13</span>:16:00.822406 IP lvs-rs1.http-alt &gt; <span class="m">10</span>.0.0.114.37644: Flags <span class="o">[</span>S.<span class="o">]</span>, seq <span class="m">4132810452</span>, ack <span class="m">2149029806</span>, win <span class="m">65160</span>, options <span class="o">[</span>mss <span class="m">1460</span>,sackOK,TS val <span class="m">11697075</span> ecr <span class="m">1594908454</span>,nop,wscale <span class="m">7</span><span class="o">]</span>, length <span class="m">0</span>
<a id="__codelineno-15-7" name="__codelineno-15-7"></a><a href="#__codelineno-15-7"><span class="linenos" data-linenos=" 7 "></span></a><span class="m">13</span>:16:00.823016 IP <span class="m">10</span>.0.0.114.37644 &gt; lvs-rs1.http-alt: Flags <span class="o">[</span>.<span class="o">]</span>, ack <span class="m">1</span>, win <span class="m">502</span>, options <span class="o">[</span>nop,nop,TS val <span class="m">1594908455</span> ecr <span class="m">11697075</span><span class="o">]</span>, length <span class="m">0</span>
<a id="__codelineno-15-8" name="__codelineno-15-8"></a><a href="#__codelineno-15-8"><span class="linenos" data-linenos=" 8 "></span></a><span class="m">13</span>:16:00.823017 IP <span class="m">10</span>.0.0.114.37644 &gt; lvs-rs1.http-alt: Flags <span class="o">[</span>P.<span class="o">]</span>, seq <span class="m">1</span>:83, ack <span class="m">1</span>, win <span class="m">502</span>, options <span class="o">[</span>nop,nop,TS val <span class="m">1594908455</span> ecr <span class="m">11697075</span><span class="o">]</span>, length <span class="m">82</span>: HTTP: GET / HTTP/1.1
<a id="__codelineno-15-9" name="__codelineno-15-9"></a><a href="#__codelineno-15-9"><span class="linenos" data-linenos=" 9 "></span></a><span class="m">13</span>:16:00.823159 IP lvs-rs1.http-alt &gt; <span class="m">10</span>.0.0.114.37644: Flags <span class="o">[</span>.<span class="o">]</span>, ack <span class="m">83</span>, win <span class="m">509</span>, options <span class="o">[</span>nop,nop,TS val <span class="m">11697076</span> ecr <span class="m">1594908455</span><span class="o">]</span>, length <span class="m">0</span>
<a id="__codelineno-15-10" name="__codelineno-15-10"></a><a href="#__codelineno-15-10"><span class="linenos" data-linenos="10 "></span></a><span class="m">13</span>:16:00.827446 IP lvs-rs1.http-alt &gt; <span class="m">10</span>.0.0.114.37644: Flags <span class="o">[</span>P.<span class="o">]</span>, seq <span class="m">1</span>:186, ack <span class="m">83</span>, win <span class="m">509</span>, options <span class="o">[</span>nop,nop,TS val <span class="m">11697080</span> ecr <span class="m">1594908455</span><span class="o">]</span>, length <span class="m">185</span>: HTTP: HTTP/1.0 <span class="m">404</span> File not found
<a id="__codelineno-15-11" name="__codelineno-15-11"></a><a href="#__codelineno-15-11"><span class="linenos" data-linenos="11 "></span></a><span class="m">13</span>:16:00.827691 IP lvs-rs1.http-alt &gt; <span class="m">10</span>.0.0.114.37644: Flags <span class="o">[</span>FP.<span class="o">]</span>, seq <span class="m">186</span>:655, ack <span class="m">83</span>, win <span class="m">509</span>, options <span class="o">[</span>nop,nop,TS val <span class="m">11697080</span> ecr <span class="m">1594908455</span><span class="o">]</span>, length <span class="m">469</span>: HTTP
<a id="__codelineno-15-12" name="__codelineno-15-12"></a><a href="#__codelineno-15-12"><span class="linenos" data-linenos="12 "></span></a><span class="m">13</span>:16:00.828006 IP <span class="m">10</span>.0.0.114.37644 &gt; lvs-rs1.http-alt: Flags <span class="o">[</span>.<span class="o">]</span>, ack <span class="m">186</span>, win <span class="m">501</span>, options <span class="o">[</span>nop,nop,TS val <span class="m">1594908460</span> ecr <span class="m">11697080</span><span class="o">]</span>, length <span class="m">0</span>
</code></pre></div>
<h2 id="6">6. 参考文献<a class="headerlink" href="#6" title="Permanent link">&para;</a></h2>
<ul>
<li>
<p><a href="http://linuxvirtualserver.org/">LVS 英文社区: http://linuxvirtualserver.org/</a></p>
</li>
<li>
<p><a href="http://zh.linuxvirtualserver.org/">LVS 中文社区: http://zh.linuxvirtualserver.org/</a></p>
</li>
<li>
<p><a href="https://www.cnblogs.com/hongdada/p/9758939.html">参考 1: IPVS 负载均衡应用及实操</a></p>
</li>
<li>
<p><a href="https://www.zsythink.net/archives/2185">参考 1: 朱双印 - LVS入门系列（2）：LVS-NAT</a></p>
</li>
<li>
<p><a href="https://www.cnblogs.com/tianzhendengni/p/13934220.html">参考 2: IPVS 集群 DR 模式</a></p>
</li>
<li>
<p><a href="https://blog.csdn.net/qq_15437667/article/details/69937553">参考 3: ipvs 负载均衡（五）源码分析</a></p>
</li>
<li>
<p><a href="https://cloud.tencent.com/developer/article/1556872">参考 4: kube-proxy ipvs 模式源码分析</a></p>
</li>
<li>
<p><a href="https://www.cnblogs.com/jinshiyill/p/4891041.html">参考 5: lvs负载均衡 ipvs的NAT模式，DR模式的实现</a></p>
</li>
</ul>

              
            </article>
          </div>
        </div>
        
      </main>
      
        <footer class="md-footer">
  
  <div class="md-footer-meta md-typeset">
    <div class="md-footer-meta__inner md-grid">
      <div class="md-copyright">
  
  
    Made with
    <a href="https://squidfunk.github.io/mkdocs-material/" target="_blank" rel="noopener">
      Material for MkDocs
    </a>
  
</div>
      
    </div>
  </div>
</footer>
      
    </div>
    <div class="md-dialog" data-md-component="dialog">
      <div class="md-dialog__inner md-typeset"></div>
    </div>
    <script id="__config" type="application/json">{"base": "../../../..", "features": ["search.suggest", "search.highlight", "navigation.tabs", "navigation.expand", "toc.follow", "toc.integrate"], "search": "../../../../assets/javascripts/workers/search.5e67fbfe.min.js", "translations": {"clipboard.copied": "Copied to clipboard", "clipboard.copy": "Copy to clipboard", "search.config.lang": "en", "search.config.pipeline": "trimmer, stopWordFilter", "search.config.separator": "[\\s\\-]+", "search.placeholder": "Search", "search.result.more.one": "1 more on this page", "search.result.more.other": "# more on this page", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents", "search.result.placeholder": "Type to start searching", "search.result.term.missing": "Missing", "select.version.title": "Select version"}, "version": {"default": "latest", "provider": "mike"}}</script>
    
    
      <script src="../../../../assets/javascripts/bundle.c44cc438.min.js"></script>
      
        <script src="../../../../static/js/util.js"></script>
      
    
  </body>
</html>